package com.example.mybatis.utils;

import java.util.HashMap;

public class ResultUtil extends HashMap<String, Object>{
	/**
	 *
	 * @param errCode 错误状态码
	 * @param errMsg 错误说明
	 */
	private ResultUtil(String errCode, String errMsg) {
		this.put("errCode", errCode);
		this.put("errMsg", errMsg);
	}


	/**
	 * 成功
	 * @return
	 */
	public static ResultUtil ok(){
		return new ResultUtil("success","成功");
	}

	/**
	 * 失败
	 * @return
	 */
	public static ResultUtil error(){
		return new ResultUtil("error","失败");
	}

	/**
	 * 失败
	 * 设置状态码、失败说明
	 * @return
	 */
	public static ResultUtil error(String errCode,String errMsg){
		return new ResultUtil(errCode,errMsg);
	}

	/**
	 * 失败
	 * 设置失败说明
	 * @return
	 */
	public static ResultUtil error(String errMsg){
		return new ResultUtil("error",errMsg);
	}

	/**
	 * 重写父类put方法
	 */
	@Override
	public ResultUtil put(String paramK, Object paramV) {
		super.put(paramK, paramV);
		return this;

	}

	
	
	
	
}
